<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Configurações SIP</title>
<link href="css/conf.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

	function sectionTypeOnChange(){
	
		var combo = document.getElementById("sectionType");
		
		var general = document.getElementById("general");
		var outros = document.getElementById("outros");
		
		if (combo.value == "general" ) {
			general.style.display = "block";
			outros.style.display = "none";
			
			document.getElementById("id").value = "general";
		
		} else {
			general.style.display = "none";
			outros.style.display = "block";
			
			document.getElementById("id").value = "";
		}
	}

</script>

</head>

<body bgcolor="#c0c0c0">

	<div align="center">
		<h2>Configuração Sip</h2>
		<h6>
			<a href="menu.jsp">Voltar ao Menu</a>
		</h6>
	</div>

	<form action='SipController?' name='controle'>

		<table width="527" border="0" align="center"
			cellpadding="1" cellspacing="1">

			<tr>
				<td colspan="2"><span class="submenus">Tipo de Seção: </span>
					<select id="sectionType" name="sectionType" onchange="sectionTypeOnChange();">
						<c:choose>
							<c:when test="${empty obj || (! empty obj && obj.id == 'general')}">
							
								<option value="general" selected="selected">General</option>
								<option value="">Outros</option>
								
								<c:set var="displayGeneral" value="block"></c:set>
								<c:set var="displayOutros" value="none"></c:set>
							
							</c:when>
							<c:otherwise>
							
								<option value="general">General</option>
								<option value=""  selected="selected">Outros</option>
							
								<c:set var="displayGeneral" value="none"></c:set>
								<c:set var="displayOutros" value="block"></c:set>
							
							</c:otherwise>
						</c:choose>
						
					</select>
				</td>
			</tr>
			
			<tr>
				<td colspan="2">
					<div id="general" style="display: ${displayGeneral};">
						<table>

							<tr>
								<td><span class="submenus">Context =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='context' id="context" value="${obj.context}" />
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">Bind Port =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='bindPort' id="bindPort" value="${obj.bindPort}" />
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">Bind Addr =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='bindAddr' id="bindAddr" value="${obj.bindAddr}"/>
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">TOS SIP =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='tos_sip' id="tos_sip" value="${obj.tos_sip}"/>
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">TOS Audio =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='tos_audio' id="tos_audio" value="${obj.tos_audio}"/>
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">TOS Video =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='tos_video' id="tos_video" value="${obj.tos_video}"/>
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">Video Support =</span></td>
								<td height="23"><span class="submenus">
									
									<select id="videoSupport" name="videoSupport">
										<c:choose>
											<c:when test="${obj.videoSupport == 'yes'}">
												<option value=""></option>
												<option value="yes" selected="selected">Yes</option>
												<option value="no">No</option>
											</c:when>
											<c:when test="${obj.videoSupport == 'no'}">
												<option value=""></option>
												<option value="yes">Yes</option>
												<option value="no" selected="selected">No</option>
											</c:when>
											<c:otherwise>
												<option value="" selected="selected"></option>
												<option value="yes">Yes</option>
												<option value="no">No</option>
											</c:otherwise>
										</c:choose>
									</select>
								
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">T38PT UDPTL =</span></td>
								<td height="23"><span class="submenus">
								
									<select id="t38pt_udptl" name="t38pt_udptl">
										<c:choose>
											<c:when test="${obj.t38pt_udptl == 'yes'}">
												<option value=""></option>
												<option value="yes" selected="selected">Yes</option>
												<option value="no">No</option>
											</c:when>
											<c:when test="${obj.t38pt_udptl == 'no'}">
												<option value=""></option>
												<option value="yes">Yes</option>
												<option value="no" selected="selected">No</option>
											</c:when>
											<c:otherwise>
												<option value="" selected="selected"></option>
												<option value="yes">Yes</option>
												<option value="no">No</option>
											</c:otherwise>
										</c:choose>
									</select>
									
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">Allow =</span></td>
								<td height="23"><span class="submenus"><input
										type='text' name='allow' id="allow" value="${obj.allow}"/>
								</span></td>
							</tr>
							
							<tr>
								<td><span class="submenus">Limit On Peers =</span></td>
								<td height="23"><span class="submenus">
								
									<select id="limitOnPeers" name="limitOnPeers">
										<c:choose>
											<c:when test="${obj.limitOnPeers == 'yes'}">
												<option value=""></option>
												<option value="yes" selected="selected">Yes</option>
												<option value="no">No</option>
											</c:when>
											<c:when test="${obj.limitOnPeers == 'no'}">
												<option value=""></option>
												<option value="yes">Yes</option>
												<option value="no" selected="selected">No</option>
											</c:when>
											<c:otherwise>
												<option value="" selected="selected"></option>
												<option value="yes">Yes</option>
												<option value="no">No</option>
											</c:otherwise>
										</c:choose>
									</select>
									
								</span></td>
							</tr>
							
						</table>
					</div>
				</td>
			</tr>
			
			
			<tr>
				<td colspan="2">
					<div id="outros" style="display: ${displayOutros};">
						<table>

							<tr>
								<td><span class="submenus">Seção =</span></td>
								<td height="23"><span class="submenus">[ <input
										type='text' name='id' maxlength="4" size="4" id="id" value="${obj.id}"/> ]
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Caller ID =</span></td>
								<td height="23"><span class="submenus"> <input
										type='text' name='callerId' id="callerId" value="${obj.callerId}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Type =</span></td>
								<td><span class="submenus"> <input type='text'
										name='type' id="type" value="${obj.type}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Username =</span></td>
								<td><span class="submenus"> <input type='text'
										name='userName' id="userName" value="${obj.userName}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Secret =</span></td>
								<td><span class="submenus"> <input type='text'
										name='secret' id="secret" value="${obj.secret}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Can Re-Invite =</span></td>
								<td><span class="submenus"> 
								
									<select id="canReInvite" name="canReInvite">
										<c:choose>
											<c:when test="${obj.canReInvite == 'yes'}">
												<option value=""></option>
												<option value="yes" selected="selected">Yes</option>
												<option value="no">No</option>
											</c:when>
											<c:when test="${obj.canReInvite == 'no'}">
												<option value=""></option>
												<option value="yes">Yes</option>
												<option value="no" selected="selected">No</option>
											</c:when>
											<c:otherwise>
												<option value="" selected="selected"></option>
												<option value="yes">Yes</option>
												<option value="no">No</option>
											</c:otherwise>
										</c:choose>
									</select>
								
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Host =</span></td>
								<td><span class="submenus"> <input type='text'
										name='host' id="host" value="${obj.host}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Context =</span></td>
								<td><span class="submenus"> <input type='text'
										name='context' id="context" value="${obj.context}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">DTMF Mode =</span></td>
								<td><span class="submenus"> <input type='text'
										name='dtmfMode' id="dtmfMode" value="${obj.dtmfMode}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">Call Limit =</span></td>
								<td><span class="submenus"> <input type='text'
										name='callLimit' id="callLimit" value="${obj.callLimit}"/>
								</span></td>
							</tr>
							<tr>
								<td><span class="submenus">NAT =</span></td>
								<td><span class="submenus"> 
									<select id="nat" name="nat">
										
										<c:choose>
											<c:when test="${obj.nat == 'yes'}">
												<option value=""></option>
												<option value="yes" selected="selected">Yes</option>
												<option value="no">No</option>
											</c:when>
											<c:when test="${obj.nat == 'no'}">
												<option value=""></option>
												<option value="yes">Yes</option>
												<option value="no" selected="selected">No</option>
											</c:when>
											<c:otherwise>
												<option value="" selected="selected"></option>
												<option value="yes">Yes</option>
												<option value="no">No</option>
											</c:otherwise>
										</c:choose>
									</select>
								
								</span></td>
							</tr>
						</table>
					</div>
				</td>
			</tr>

			<tr>
				<td colspan="2" align="center" valign="bottom"><input type='submit'
					class="textoBolt" value='Confirmar' /></td>
			</tr>


		</table>

		<p>&nbsp;</p>

		<input type="hidden" name="act" id="act" value="${requestScope.act}" />

	</form>

	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="10" style="background-color: lightgrey"><b>GENERAL</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<td width="9%"><strong>Context</strong></td>
			<td width="9%"><strong>Bind Port</strong></td>
			<td width="9%"><strong>Bind Addr</strong></td>
			<td width="9%"><strong>TOS SIP</strong></td>
			<td width="9%"><strong>TOS Audio</strong></td>
			<td width="9%"><strong>TOS Video</strong></td>
			<td width="9%"><strong>Video Support</strong></td>
			<td width="9%"><strong>T38PT UDPTL</strong></td>
			<td width="9%"><strong>Allow</strong></td>
			<td width="9%"><strong>Limit On Peers</strong></td>
			<td width="5%"><strong>&nbsp;</strong></td>
			<td width="5%"><strong>&nbsp;</strong></td>
		</tr>
	
		<tbody>
			<c:forEach items="${requestScope.lista}" var="sip" >
			
				<c:if test="${sip.id == 'general'}">
					<tr>
						<td>${sip.context}</td>
						<td>${sip.bindPort}</td>
						<td>${sip.bindAddr}</td>
						<td>${sip.tos_sip}</td>
						<td>${sip.tos_audio}</td>
						<td>${sip.tos_video}</td>
						<td>${sip.videoSupport}</td>
						<td>${sip.t38pt_udptl}</td>
						<td>${sip.allow}</td>
						<td>${sip.limitOnPeers}</td>
						
						<td width="52"><input name="alterar" type="button" class="rodape" id="alterar" value="Alterar" onclick="document.location.href='SipController?act=retrieve&id=${sip.id}'"/></td>
						<td width="56"><input name="Deletar" type="submit" class="rodape" id="Deletar" value="Deletar"  onclick="document.location.href='SipController?act=delete&id=${sip.id}'"/></td>
					</tr>
				</c:if>
				
			</c:forEach>
		</tbody>

	</table>

	<table width="899" border="1" cellspacing="0" cellpadding="1"
		align="center" style="border: 1px thin solid;">
		
		<tr>
			<td colspan="13" style="background-color: lightgrey"><b>SECTIONS</b></td>
		</tr>
		
		<tr class="texto" style="background-color: lightgrey">
			<td><strong>Seção</strong></td>
			<td><strong>Caller ID</strong></td>
			<td><strong>Type</strong></td>
			<td><strong>Username</strong></td>
			<td><strong>Secret</strong></td>
			<td><strong>Can Re-Invite</strong></td>
			<td><strong>Host</strong></td>
			<td><strong>Context</strong></td>
			<td><strong>DTMF Mode</strong></td>
			<td><strong>Call-Limit</strong></td>
			<td><strong>NAT</strong></td>
			<td><strong>&nbsp;</strong></td>
			<td><strong>&nbsp;</strong></td>
		</tr>
	
		<c:forEach items="${requestScope.lista}" var="sip" >

				<c:if test="${sip.id != 'general'}">
					<tr>
						<td>${sip.id}</td>
						<td>${sip.callerId}</td>
						<td>${sip.type}</td>
						<td>${sip.userName}</td>
						<td>${sip.secret}</td>
						<td>${sip.canReInvite}</td>
						<td>${sip.host}</td>
						<td>${sip.context}</td>
						<td>${sip.dtmfMode}</td>
						<td>${sip.callLimit}</td>
						<td>${sip.nat}</td>
						
						<td width="52"><input name="alterar" type="button" class="rodape" id="alterar" value="Alterar" onclick="document.location.href='SipController?act=retrieve&id=${sip.id}'"/></td>
						<td width="56"><input name="Deletar" type="submit" class="rodape" id="Deletar" value="Deletar" onclick="document.location.href='SipController?act=delete&id=${sip.id}'"/></td>
					</tr>
				</c:if>

		</c:forEach>

	</table>
</body>

</html>
